<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.wwdx.shiro.SessionUser" %>
<html>
<head>
    <jsp:include page="/public/inc/head.jsp"/>
    <script type="text/javascript">
        
        var $table;
        $(function () {
            var url = "/system/wwdx_order/list";
            tableInit(url);
            
            //查询  
            $('#searchBtn').click(function () {
                $table.bootstrapTable('refresh');
            });
            
            //清空
            $('#clearBtn').click(function () {
                $('#myform')[0].reset();
                $table.bootstrapTable('refresh');
            });
            
            //导出
            $('#exportExcel').click(function () {
                $("#myModal2").modal('show');
                $("#showInfo2").html("正在发送……");
                $.get("/system/wwdx_order/export",{email:'<%=SessionUser.getEmail()%>'},function (data) {
                    $("#showInfo2").empty().html(data.data);
                    setTimeout(function (args) { $("#myModal2").modal('hide') },2000);
                    $("#exportExcel").attr("disabled", true);
                });
            });
        });
           
        /**
         * 用户列表
         */
        function tableInit(url) {
            $table = $("#table").bootstrapTable({
                url: url,                           //请求后台的URL（*）
                cache: false,
                striped: true,                      //是否显示行间隔色
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pagination: true,                   //是否显示分页（*）
                showJumpto:true,
                paginationPreText:'上一页',
                paginationNextText:'下一页',
                height:570,
                toolbar:"#toolbar",
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                showExport: true,
                exportTypes:['excel'],              //导出文件类型
                //得到查询的参数
                queryParams : function (params) {
                    return {
                        rows: params.limit,                         //页面大小
                        page: (params.offset / params.limit) + 1,    //页码
                        status:$("#status").val(),
                        type:$("#type").val(),
                        channel:$("#channel").val(),
                        payType:$("#payType").val()
                    };
                },
                columns: [{
                    title : '序号',
                    align: "center",
                    width: 40,
                    formatter: function (value, row, index) {
                        //获取每页显示的数量
                        var pageSize = $table.bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页  
                        var pageNumber = $table.bootstrapTable('getOptions').pageNumber;
                        //返回序号，注意index是从0开始的，所以要加上1
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                }, {
                    field: 'type',
                    title: '产品类型',
                    formatter:function (value) {
                        var type;
                        if (value === 1){
                            type = "阅读包";
                        }else if (value === 2){
                            type = "解读版";
                        }else if (value === 3){
                            type = "虚拟币";
                        }else if (value === 4){
                            type = "小课";
                        }else if (value === 7){
                            type = "会员";
                        }else {
                            type = "其他";
                        }
                        return type;
                    }
                }, {
                    field: 'price',
                    title: '价格'
                }, {
                    field: 'productName',
                    title: '产品名称'
                }, {
                    field: 'memberName',
                    title: '用户名称'
                }, {
                    field: 'payType',
                    title: '支付类型',
                    formatter:function (value) {
                        var payType;
                        if (value === 11){
                            payType = "支付宝";
                        }else if (value === 121){
                            payType = "微信APP";
                        }else if (value === 122){
                            payType = "微信H5";
                        }else if (value === 123){
                            payType = "微信小程序";
                        }else if (value === 131){
                            payType = "虚拟币充值";
                        }else if (value === 132){
                            payType = "虚拟币消费";
                        }else if (value === 14){
                            payType = "赠一得一";
                        }else if (value === 15){
                            payType = "兑换码";
                        }
                        return payType;
                    }
                }, {
                    field: 'channel',
                    title: '渠道',
                    formatter:function (value) {
                        var channel;
                        if (value === 'weixin'){
                            channel = "微信公众号";
                        }else if (value === 'android'){
                            channel = "安卓APP";
                        }else if (value === 'wxma'){
                            channel = "微信小程序";
                        }else {
                            channel = "苹果APP";
                        }
                        return channel;
                    }
                }, {
                    field: 'createTime',
                    title: '支付时间'
                }, {
                    field: 'status',
                    title: '是否支付',
                    formatter:function (value) {
                        var isPay;
                        if (value === 1){
                            isPay = "<span class=\"label label-primary\">已支付</span>";
                        }else {
                            isPay = "<span class=\"label label-default\">未支付</span>";
                        }
                        return isPay;
                    }
                }],
                onLoadSuccess: function () {
                },
                onLoadError: function () {
                    alert("数据加载失败！");
                },
                onDblClickRow: function (row, $element) {
                }
            });
        }
    </script>
</head>
<body>
<div id="header" class="navbar navbar-static-top" role="navigation">
    <jsp:include page="/public/inc/top.jsp"/>
</div>
<div class="container-fluid" style="margin-top:5px;margin-bottom:60px;">
    <div class="row">
        <jsp:include page="/public/inc/menu.jsp"/>
        <div class="col-xs-12 col-sm-10">
            <div id="toolbar">
                <form id="myform">
                    <label>
                        <select id="channel" name="channel" class="form-control">
                            <option value="">渠道</option>
                            <option value="weixin">微信公众号</option>
                            <option value="android">安卓APP</option>
                            <option value="wxma">微信小程序</option>
                            <option value="ios">苹果APP</option>
                        </select>
                    </label>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label>
                        <select id="payType" name="payType" class="form-control">
                            <option value="">支付类型</option>
                            <option value="11">支付宝</option>
                            <option value="121">微信APP</option>
                            <option value="122">微信H5</option>
                            <option value="123">微信小程序</option>
                            <option value="131">虚拟币充值</option>
                            <option value="132">虚拟币消费</option>
                            <option value="14">赠一得一</option>
                            <option value="15">兑换码</option>
                        </select>
                    </label>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label>
                        <select id="status" name="status" class="form-control">
                            <option value="">支付状态</option>
                            <option value="1">已支付</option>
                            <option value="0">未支付</option>
                        </select>
                    </label>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label>
                        <select id="type" name="type" class="form-control">
                            <option value="">产品类型</option>
                            <option value="1">阅读包</option>
                            <option value="2">解读版</option>
                            <option value="3">阅读币</option>
                            <option value="4">小课</option>
                            <option value="7">会员</option>
                        </select>
                    </label>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <button type="button" id="searchBtn" class="btn btn-default">筛选</button>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <button type="reset" id="clearBtn" class="btn btn-default">清空</button>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <button type="button" id="exportExcel" class="btn btn-default">Excel</button>
                </form>
            </div>
            <table id="table"></table>
            <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h4 class="modal-title" id="myModalLabel2">通知</h4>
                        </div>
                        <div id="showInfo2" class="modal-body"></div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="/public/inc/bottom.jsp"/>
</body>
</html>